/*
 * 数据字典接口
 * @Description: jishupu-admin-template
 * @Author: 技术铺<jishupu@qq.com>
 * @Date: 2021-11-15
 */
import request from '@/utils/request'

/**
 * 列表
 * @param {Object} params
 * @param {Object} extendConfig
 * @returns  new Promise
 */
export function index(params, extendConfig) {
  return request.get('/v1/dictionary', { params, ...extendConfig })
}

/**
 * store 添加
 * @param {Object} params
 * @param {Object} extendConfig
 * @returns  new Promise
 */
export function store(params, extendConfig) {
  return request.post('/v1/dictionary', params, extendConfig)
}

/**
 * 查看
 * @param {Number} id 标识
 * @param {Object} extendConfig
 * @returns  new Promise
 */
export function show(id, extendConfig) {
  return request.get('/v1/dictionary/' + id, extendConfig)
}

/**
 * update 修改
 * @param {Number} id 标识
 * @param {Object} params
 * @param {Object} extendConfig
 * @returns  new Promise
 */
export function update(id, params, extendConfig) {
  return request.put(`/v1/dictionary/${id}`, params, extendConfig)
}

/**
 * 删除
 * @param {Number|String} id  例：数字1或字符串1,2,3
 * @param {Object} extendConfig
 * @returns  new Promise
 */
export function destory(id, extendConfig) {
  return request.delete(`/v1/dictionary/${id}`, extendConfig)
}

/**
 * 更新状态
 * @param {Number} id 标识
 * @param {Object} params 参数如： { status: 0 }
 * @param {Object} extendConfig
 * @returns  new Promise
 */
export function updateStatus(id, params, extendConfig) {
  return request.patch(`/v1/dictionary/${id}/status`, params, extendConfig)
}

/**
 * 获取所有数据字典公共配置
 * @param {Object} extendConfig
 * @returns  new Promise
 */
export function getCommonConfig(extendConfig) {
  return request.get('/v1/dictionary/common-config', extendConfig)
}
